package helper

import (
	"gin-study/app/services"
	"github.com/gin-gonic/gin"
	"net/http"
)

func WarpHandle(fn func(c *gin.Context) interface{}) gin.HandlerFunc {
	return func(c *gin.Context) {
		res := fn(c)
		if res != nil {
			services.Ctx.SetResponse(c, res)
			c.JSON(http.StatusOK, res)
			c.Abort()
		}
	}
}
